package foo.bar.wiki.web.action.general;

import foo.bar.wiki.web.action.BaseActionBean;
import foo.bar.wiki.web.nonextension.NullResolution;
import foo.bar.wiki.security.RoleType;
import foo.bar.wiki.services.ThemeService;

import java.util.Set;
import java.util.LinkedHashSet;
import java.util.EnumSet;
import java.net.URISyntaxException;

import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.integration.spring.SpringBean;

/**
 * @author tmjee
 * @version $Date$ $Id$
 */
public class UtilitiesActionBean extends BaseActionBean {

    private ThemeService themeService;


    // =============== Roles ==========================
    private Set<RoleType> roles;

    public Resolution roles() {
        roles = EnumSet.allOf(RoleType.class);
        return new NullResolution();
    }


    public Set<RoleType> getRoles() {
        return roles;
    }

    public void setRoles(Set<RoleType> roles) {
        this.roles = roles;
    }



    // ========================= Themes ===========================
    private Set<String> themes;

    public Resolution themes() throws URISyntaxException {
        themes = themeService.getAllWikiThemeNames();
        return new NullResolution();
    }

    public Set<String> getThemes() {
        return themes;
    }

    public void setThemes(Set<String> themes) {
        this.themes = themes;
    }










    // ==== Injection ==========================

    @SpringBean("themeService")
    public void setThemeService(ThemeService themeService) {
        this.themeService = themeService;
    }
}
